<?php

class Admin_Model_Product extends Libs_Model{
    private $tbl = 'product';
   public function getProductLimit($start,$record){
       $sql = "SELECT * FROM product LIMIT $start, $record";
       return $this->db->fetchAll($sql);
   }
   public function lastId(){
       $last_id = $this->db->_id;
       return $last_id;
   }
     public function InsertProduct($data){
       $this->db->prepareInsert($data);
       $result = $this->db->insert($this->tbl);
       if($result == true){
           return true;
       }else{
           return false;
       }
   }
   public function getProductById($id =''){
       $sql = "SELECT * FROM product WHERE id = $id";
       return $this->db->fetchOne($sql);
   }
   public function getCate($id=''){
       $sql = "SELECT cate_id FROM product WHERE id = $id";
        return $this->db->fetchOne($sql);
   }
   public function getCateS($id=''){
       $sql = "SELECT cates_id FROM product WHERE id = $id";
        return $this->db->fetchOne($sql);
   }
   public function UpdateProduct($data, $id){
       $this->db->prepareUpdate($data);
       $this->db-> update($this->tbl,$id);
   }
   public function deleteProduct($id){
       $sql = "DELETE FROM product WHERE id = $id";
       $result = mysql_query($sql);
       if($result == true){
           return true;
       }else{
           return false;
       }
   }
    public function deleteDetailProduct($id){
       $sql = "DELETE FROM product_detail WHERE id = $id";
       $result = mysql_query($sql);
       if($result == true){
           return true;
       }else{
           return false;
       }
   }
     public function getProductDetailLimit($start,$record){
       $sql = "SELECT * FROM product_detail LIMIT $start, $record";
       return $this->db->fetchAll($sql);
   }
   
}

?>
